package com.jrx.anytxn.transaction.job.autoPayment.step;

import com.jrx.anytxn.transaction.constant.TransBizConstant;
import com.jrx.anytxn.transaction.entity.TlPaymentLog;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.batch.MyBatisPagingItemReader;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 第三次批扣初始化读取上次非足额扣款成功记录
 *
 * @Author yhy
 * @Date 2023/4/25 17:33
 */
public class AutoPaymentThirdPartSuccessInitReader extends MyBatisPagingItemReader<TlPaymentLog> {

    /**
     * 获取上次非足额扣款成功的流水
     * @param businessDate 当前业务日期
     * @param sqlSessionFactory  sql工厂对象
     * @param pageSize 分页参数
     */
    public AutoPaymentThirdPartSuccessInitReader(Date businessDate, SqlSessionFactory sqlSessionFactory, Integer pageSize){
        setSaveState(false);
        setPageSize(pageSize);
        setSqlSessionFactory(sqlSessionFactory);
        setQueryId("com.jrx.anytxn.transaction.mapper.ext.ExtTlPaymentLogMapper.selectBySumStatusAndSettleFlag");
        Map<String, Object> map = new HashMap<>();
        map.put("businessDate",businessDate);
        // 交易状态为成功
        map.put("sumStatus", TransBizConstant.PAYMENT_LOG_SUM_STATUS_S);
        // 默认查询批扣交易记录
        map.put("paymentType", TransBizConstant.REPAYMENT_TYPE_AUTO);
        // 是否足额还款 0 否 1 是
        map.put("settleFlag",TransBizConstant.SETTLE_FLAG_0);
        setParameterValues(map);
    }
}
